//
//  ApprovalDetailController.m
//  Marketing
//
//  Created by Hanen 3G 01 on 16/3/3.
//  Copyright © 2016年 Hanen 3G 01. All rights reserved.
//审批详情

#import "ApprovalDetailController.h"
#import "ApproSubVIew.h"
#import "myButton.h"
#define SectionH 17.0f
@interface ApprovalDetailController ()
{
//    UITableView     *_scrollView;
    UIScrollView    *_scrollView;
    CGFloat labelW;
    CGFloat labelH;
    CGFloat     topSpace;
    UIView    *_leavingView;//请假视图
    UIImageView     *_personLogo;
    UIImageView     *_waiteLoga;
    UILabel         *_nameLabel;
    UILabel         *_waiteLabel;
    UILabel         *_dateLabel;
    UILabel         *_timeLabel;
    
    UIView          *_btnView;
    UIButton        *_agreeBtn;
    UIButton        *_rejectBtn;
    
    NSDictionary    *_dataDict;
    NSMutableArray * titleArray2;
    NSArray * titleArray;
    ApproSubVIew * approView1;
    ApproSubVIew * approView2;
      UIView *botto;
}
@end

@implementation ApprovalDetailController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = lightGrayBackColor;
    titleArray2 = [NSMutableArray arrayWithCapacity:0];
    self.navigationItem.leftBarButtonItem = [ViewTool getBarButtonItemWithTarget:self WithAction:@selector(popViewControll)];
    self.navigationItem.titleView = [ViewTool getNavigitionTitleLabel:[NSString stringWithFormat:@"%@的请假",self.leavingPersonName]];
    
    [self initScrollView];
    [self addLeavingView];
    if (_lstatus == 0) {//未审批的时候 才添加button
        [self addBtn];
    }
    
//    [self initData];
    
}
- (void)initData
{
  
    
    NSDictionary *paramDict = [DataTool changeType:@{@"token" : TOKEN,@"uid" : @(UID),@"id" :@(self.approID)}];
    NSLog(@"%@",paramDict);
//    [DataTool sendGetWithUrl:LEAVING_DETAIL_URL parameters:paramDict success:^(id data) {
//        id backData = CRMJsonParserWithData(data);
//         NSLog(@"backData %@",backData);
//        
//        _dataDict = [DataTool changeType:backData];
////        NSLog(@"%@",_dataDict);
//        titleArray2 = [NSMutableArray arrayWithArray:@[_dataDict[@"leave"][@"dealno"],_dataDict[@"department"],_dataDict[@"leave"][@"typename"],_dataDict[@"leave"][@"begintime"],_dataDict[@"leave"][@"endtime"],_dataDict[@"leave"][@"days"],_dataDict[@"leave"][@"reason"]]];
//        
//        [self useData];
//    } fail:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
     [SVProgressHUD show];
    [DataTool postWithUrl:LEAVING_DETAIL_URL parameters:paramDict success:^(id data) {
               [SVProgressHUD dismiss];
        id backData = CRMJsonParserWithData(data);
        if ([backData[@"code"] intValue] == 100) {
            NSLog(@"backData %@",backData);
            
            _dataDict = [DataTool changeType:backData];
            //        NSLog(@"%@",_dataDict);
            titleArray2 = [NSMutableArray arrayWithArray:@[_dataDict[@"leave"][@"dealno"],_dataDict[@"department"],_dataDict[@"leave"][@"typename"],_dataDict[@"leave"][@"begintime"],_dataDict[@"leave"][@"endtime"],_dataDict[@"leave"][@"days"],_dataDict[@"leave"][@"reason"]]];
            
            [self useData];
        }else{
            [self.view makeToast:backData[@"message"]];
             [SVProgressHUD dismiss];
        }
      
    } fail:^(NSError *error) {
           NSLog(@"%@",error.localizedDescription);
         [SVProgressHUD dismiss];
    }];
}

- (void)useData
{
    NSLog(@"开始时间%@",_dataDict[@"leave"][@"begintime"]);
    _dateLabel.text = [DateTool getYearmonthFromStr:_dataDict[@"leave"][@"addtime"]];
    _timeLabel.text = [DateTool getDateFromStr:_dataDict[@"leave"][@"addtime"]];
    
    int status = [_dataDict[@"leave"][@"status"] intValue];
    if (status == 0) {
        _waiteLoga.hidden = NO;
        _waiteLoga.image = [UIImage imageNamed:@"等待"];
    }else{
        _waiteLoga.image = [UIImage imageNamed:@"完成"];
        _waiteLoga.hidden = YES;
        
    }
    approView1.approvalState = status; //0 待通过 1 通过
    approView1.nameString = @"  ";
    
    
    approView2.approvalState = status;
    approView2.nameString = @"我";
    
    approView1.postApproName = self.leavingPersonName;
    approView1.leavingPersonLogo = self.leavingPersonLogo;
    approView1.nameString = self.leavingPersonName;
    
    approView2.upLabel.hidden = YES;
    
    
    approView2.handleLeavingLogo = [[NSUserDefaults standardUserDefaults] objectForKey:@"logo"];
    approView1.apptype = 0;
    approView2.apptype = 1;
    
//    approView2.handleLeavingLogo = [[NSUserDefaults standardUserDefaults] objectForKey:@"logo"];
//    approView2.nameString = [[NSUserDefaults standardUserDefaults] ]
    for (int i = 0; i< titleArray2.count; i++) {
        
//         NSLog(@"titleArray2 %@",titleArray2[i]);
        UILabel * label = [_leavingView viewWithTag:7788 + i];
        //给每个label 信息赋值  有一个请假天数不是字符串类型的 是int
        if ([titleArray2[i] isKindOfClass:[NSString class]]) {
            label.text = titleArray2[i];
        }else{
            label.text = [NSString stringWithFormat:@"%@",titleArray2[i]];
//            label.backgroundColor = [UIColor redColor];
//            NSLog(@"天数 ==%@",titleArray2[i]);
        }
        if (i == titleArray2.count -1) {
            label.numberOfLines = 0;
//#warning 获得请假事由计算高度
            if (label.text != nil) {
                CGRect frame = label.frame;
                CGFloat h = [label.text boundingRectWithSize:CGSizeMake(label.width, MAXFLOAT) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:16.0f], NSForegroundColorAttributeName : blackFontColor} context:nil].size.height;
                if (h<40.0f) {//40.0发是 每个最低的 高度
                    h = 40.0f;
                }
                label.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, h);
            }
         
            _leavingView.frame = CGRectMake(0, 0, KSCreenW, label.maxY + topSpace);
        }
    }
    UIView *line1 = [ViewTool getLineViewWith:CGRectMake(0, _leavingView.maxY - 1, KSCreenW , 1) withBackgroudColor:lightGrayBackColor];
    [_leavingView addSubview:line1];
    
    CGRect frame = botto.frame;
    frame.origin.y = _leavingView.maxY + SectionH;
    botto.frame = frame;
//    approView1.frame = CGRectMake(3 * topSpace,_leavingView.maxY + 2 * topSpace, KSCreenW - 6 * topSpace, [UIView getWidth:60]);
//    approView2.frame = CGRectMake(3 * topSpace, approView1.maxY + 2 * topSpace, KSCreenW - 6 * topSpace, [UIView getWidth:60]);
    
//    UIView *linV = [ViewTool getLineViewWith:CGRectMake(approView2.x + approView1.approvalStateImage.width / 2.0f, _leavingView.maxY, 1, approView1.y - _leavingView.maxY) withBackgroudColor:grayLineColor];
//    [_scrollView addSubview:linV];
//    
//    UIView *linV2 = [ViewTool getLineViewWith:CGRectMake(approView2.x + approView1.approvalStateImage.width / 2.0f, linV.maxY + approView1.approvalStateImage.height + 1, 1, approView2.y - linV.maxY - approView1.approvalStateImage.height) withBackgroudColor:grayLineColor];
//    [_scrollView addSubview:linV2];
    CGFloat diffsdf;
    if(status == 0){
    if (botto.maxY < KSCreenH - 70.0f - 64) {
        diffsdf = KSCreenH - 70 - botto.maxY - 64 + 30;
        UIView *vi = [ViewTool getLineViewWith:CGRectMake(0, botto.maxY, KSCreenW, diffsdf) withBackgroudColor:graySectionColor];
        [_scrollView addSubview:vi];
        _scrollView.contentSize = CGSizeMake(KSCreenW, vi.maxY+ 10);
    }else{
        _scrollView.contentSize = CGSizeMake(0, botto.maxY + 30.0f);
    }
    }else{
        CGRect scrolFrem = _scrollView.frame;
        scrolFrem.size.height = KSCreenH - 64;
        _scrollView.frame = scrolFrem;
        
        if (botto.maxY < KSCreenH  - 64) {
            diffsdf = KSCreenH - botto.maxY - 64 + 30;
            UIView *vi = [ViewTool getLineViewWith:CGRectMake(0, botto.maxY, KSCreenW, diffsdf) withBackgroudColor:graySectionColor];
            [_scrollView addSubview:vi];
            _scrollView.contentSize = CGSizeMake(KSCreenW, vi.maxY+ 10);
        }else{
            _scrollView.contentSize = CGSizeMake(0, botto.maxY + 30.0f);
        }

    }

//    if (botto.maxY > KSCreenH - 70.0f) {
//        _scrollView.contentSize = CGSizeMake(0, botto.maxY + topSpace + 70.0f);
//    }

}
- (void)initScrollView
{
//     _scrollView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KSCreenH, KSCreenH - 70.0f )];
//    _scrollView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KSCreenH, KSCreenH - 70.0f - 64)];
    _scrollView.backgroundColor = graySectionColor;
    [self.view addSubview:_scrollView];
    
}
- (void)addLeavingView
{
    
    if (IPhone4SInCell) {
        topSpace = 6.0f;
    }else{
        topSpace = [UIView getWidth:8.0f];
    }
    _leavingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KSCreenW, [UIView getWidth:300])];
    _leavingView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_leavingView];
    
    
    CGFloat logoW = [UIView getWidth:50];
     _personLogo = [[UIImageView alloc] initWithFrame:CGRectMake(2 * topSpace, topSpace, logoW, logoW)];
    _personLogo.backgroundColor = blueFontColor;
    _personLogo.layer.cornerRadius = logoW / 2.0f;
    _personLogo.layer.masksToBounds = YES;
    [_personLogo sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LoadImageUrl,self.leavingPersonLogo]] placeholderImage:nil];
    [_leavingView addSubview:_personLogo];
    
    CGFloat waiteLogoW = [UIView getWidth:13.0f];
    _waiteLoga = [[UIImageView alloc] initWithFrame:CGRectMake(logoW , _personLogo.maxY - waiteLogoW, waiteLogoW , waiteLogoW)];
    //    _waiteLoga.backgroundColor = [UIColor redColor];
//    if (self.lstatus == 0) {
//        _waiteLoga.image = [UIImage imageNamed:@"等待"];
//    }else{
//        _waiteLoga.image = [UIImage imageNamed:@"完成"];
//
//    }
//      [ _leavingView addSubview:_waiteLoga];
    
    _nameLabel = [ViewTool getLabelWith:CGRectMake(_personLogo.maxX + 2 * topSpace, _personLogo.y + _personLogo.height / 2.0f - ([UIView getHeight:15]) , KSCreenW - _personLogo.maxX - 4 * topSpace, [UIView getHeight:15]) WithTitle:self.leavingPersonName WithFontSize:15.0f WithTitleColor:blackFontColor WithTextAlignment:NSTextAlignmentLeft];
    
    [_leavingView addSubview:_nameLabel];
    
    _waiteLabel = [ViewTool getLabelWith:CGRectMake(_nameLabel.x, _nameLabel.maxY, [UIView getWidth:100], [UIView getHeight:15]) WithTitle:@" " WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
    if (self.lstatus ) {
        _waiteLabel.text = @"已完成审批";
    }else{
        _waiteLabel.text = @"等待我的审批";
    }
    [_leavingView addSubview:_waiteLabel];
    
    CGFloat dateW = [UIView getWidth:80];
    CGFloat dateX = KSCreenW - 2 * topSpace - dateW;
    _dateLabel = [ViewTool getLabelWith:CGRectMake(dateX , _nameLabel.maxY - [UIView getHeight:15.0f], dateW, [UIView getHeight:15]) WithTitle:@"..." WithFontSize:15.0f WithTitleColor:greenBackColor WithTextAlignment:NSTextAlignmentRight];
    //    _dateLabel.backgroundColor = [UIColor orangeColor];
    [_leavingView addSubview:_dateLabel];
    
    CGFloat timeW = [UIView getWidth:60];
    CGFloat timeX = KSCreenW - 2 * topSpace - timeW;
    _timeLabel = [ViewTool getLabelWith:CGRectMake(timeX, _waiteLabel.y,timeW, [UIView getHeight:15])  WithTitle:@"  " WithFontSize:14.0f WithTitleColor:greenBackColor WithTextAlignment:NSTextAlignmentRight];
    [_leavingView addSubview:_timeLabel];
    
    UIView *line = [ViewTool getLineViewWith:CGRectMake(0, _personLogo.maxY + topSpace , KSCreenW, SectionH) withBackgroudColor:graySectionColor];
    [_leavingView addSubview:line];
    UIView *l1 = [ViewTool getLineViewWith:CGRectMake(0, 0 , KSCreenW, 1) withBackgroudColor:grayLineColor];
    
    UIView *l2 = [ViewTool getLineViewWith:CGRectMake(0, line.height - 1 , KSCreenW, 1) withBackgroudColor:grayLineColor];
    [line addSubview:l1];
    [line addSubview:l2];
    
    
    titleArray = @[@"审批编号",@"所在部门",@"请假类型",@"开始时间",@"结束时间",@"请假天数",@"请假事由"];
//     NSArray * titleArray2 = @[@"7823478-1-3249",@"所在部门",@"请假类型",@"开始时间",@"结束时间",@"请假天数",@"请假事由"];
    for (int i = 0; i < titleArray.count ; i ++) {
        labelW = [UIView getWidth:60];
        //        labelH = [UIView getWidth:0.0];
        labelH = 40.0f;
        CGFloat contentLabelH = 40.0f;
        UILabel *label = [ViewTool getLabelWith:CGRectMake(2 * topSpace, line.maxY  + i * (labelH ), labelW, labelH) WithTitle:titleArray[i] WithFontSize:15.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
        [_leavingView addSubview:label];
        
         UILabel *contentLabel = [ViewTool getLabelWith:CGRectMake(label.maxX , label.y, KSCreenW - label.maxX - 2 * topSpace, contentLabelH) WithTitle:@" " WithFontSize:16.0f WithTitleColor:blackFontColor WithTextAlignment:NSTextAlignmentLeft];
        contentLabel.tag = 7788 + i;
//        contentLabel.backgroundColor = blueFontColor;
        [_leavingView addSubview:contentLabel];
    
        //最后一个请假事由可以根据字数来设定label的高度
        if (i == titleArray.count -1) {
            contentLabel.numberOfLines = 0;
#warning 获得请假事由计算高度
//            CGFloat h = [contentLabel.text boundingRectWithSize:CGSizeMake(contentLabel.width, MAXFLOAT) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13.0f], NSForegroundColorAttributeName : grayFontColor} context:nil].size.height;
//            contentLabel.frame = CGRectMake(label.maxX + topSpace, topSpace + i * (labelH + 0.5 * topSpace), KSCreenW - label.maxX - 2 * topSpace, h);
            _leavingView.frame = CGRectMake(0, 0, KSCreenW, contentLabel.maxY + topSpace);
        }else{
            UIView *l = [ViewTool getLineViewWith:CGRectMake(label.x, label.maxY , KSCreenW - label.x, 1.0f) withBackgroudColor:grayLineColor];
            [_leavingView addSubview:l];
        }
    }
//    _leavingView.backgroundColor = [UIColor redColor];
     [self addBottonView];
//     approView1 = [[ApproSubVIew alloc] initWithFrame:CGRectMake(3 * topSpace,_leavingView.maxY + 2 * topSpace, KSCreenW - 6 * topSpace, [UIView getWidth:60])];
////    approView1.isHadApproval = NO;//这里就传前面的type类型对应的数字
//  
//    approView1.approvalState = self.lstatus; //0 待通过 1 通过
//    approView1.nameString = @"  ";
//    
//   approView2 = [[ApproSubVIew alloc] initWithFrame:CGRectMake(3 * topSpace, approView1.maxY + 2 * topSpace, KSCreenW - 6 * topSpace, [UIView getWidth:60])];
////    approView2.isHadApproval = NO;
//   
//    //在给赋值的时候 是放在approView 的setType 方法里的 所有 设定typ之前要先有 状态的，头像的 值
//    approView2.approvalState = self.lstatus;
//    approView2.nameString = @"我";
//    
//    approView1.postApproName = self.leavingPersonName;
//    approView1.leavingPersonLogo = self.leavingPersonLogo;
//    approView1.nameString = self.leavingPersonName;
//    
//    approView2.handleLeavingLogo = [[NSUserDefaults standardUserDefaults] objectForKey:@"logo"];
//      approView1.apptype = 0;
//     approView2.apptype = 1;
////    UIView *linV = [ViewTool getLineViewWith:CGRectMake(approView2.x + approView1.approvalStateImage.width / 2.0f, _leavingView.maxY, 0.5, approView2.y - _leavingView.maxY) withBackgroudColor:grayLineColor];
////    [_scrollView addSubview:linV];
//    
//    [_scrollView addSubview:approView1];
//    [_scrollView addSubview:approView2];
//    
//    
//   
//    
//    if (approView2.maxY + 64 > KSCreenH - TabbarH) {
//        _scrollView.contentSize = CGSizeMake(0, approView2.maxY + TabbarH);
//    }else{
//        _scrollView.contentSize = CGSizeMake(0, 0);
//    }
//    
}
- (void)addBottonView
{
    botto = [ViewTool getLineViewWith:CGRectMake(0, _leavingView.maxY + SectionH, KSCreenW, [UIView getWidth:60] * 2 ) withBackgroudColor:[UIColor whiteColor]];
    [_scrollView addSubview:botto];
    
    //需要审批的额
    approView2 = [[ApproSubVIew alloc] initWithFrame:CGRectMake(0,  0, KSCreenW, [UIView getWidth:60])];
    //发起申请的
    approView1 = [[ApproSubVIew alloc] initWithFrame:CGRectMake(0, approView2.maxY, KSCreenW , [UIView getWidth:60])];
    
//    approView1.approvalState = self.lstatus; //0 待通过 1 通过
//    approView1.nameString = @"  ";
//    
//    
//    approView2.approvalState = self.lstatus;
//    approView2.nameString = @"我";
//    
//    approView1.postApproName = self.leavingPersonName;
//    approView1.leavingPersonLogo = self.leavingPersonLogo;
//    approView1.nameString = self.leavingPersonName;
//   
//    approView2.upLabel.hidden = YES;
//    
//    
//    approView2.handleLeavingLogo = [[NSUserDefaults standardUserDefaults] objectForKey:@"logo"];
//    approView1.apptype = 0;
//    approView2.apptype = 1;
    
    
    
    [botto addSubview:approView1];
    [botto addSubview:approView2];
    
    
    if (botto.maxY + 64 > KSCreenH - 80.0f) {
        _scrollView.contentSize = CGSizeMake(0, botto.maxY + 80.0f);
    }else{
        _scrollView.contentSize = CGSizeMake(0, 0);
    }
    
//    NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"name"];
//    NSLog(@"用户名字%@",username);
//    approView1.nameString = [NSString stringWithFormat:@"我(%@)",username];
//    approView1.leavingPersonLogo = [[NSUserDefaults standardUserDefaults] objectForKey:@"logo"];
//    //    NSLog(<#NSString * _Nonnull format, ...#>)
//    

    
}


- (void)addBtn
{
    _btnView = [[UIView alloc] initWithFrame:CGRectMake(0, KSCreenH - 70.0f - 64, KSCreenW, 70.0f)];
    _btnView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_btnView];
    
    UIView *linelineline = [ViewTool getLineViewWith:CGRectMake(0, 0, KSCreenW, 1) withBackgroudColor:grayLineColor];
    [_btnView addSubview:linelineline];
    
    
    _agreeBtn = [[UIButton alloc] initWithFrame:CGRectMake(KSCreenW / 2.0f + 15.0 + 3, 9, KSCreenW / 2.0f - 30.0f, 70.0f - 16)];
    _agreeBtn.layer.cornerRadius =5.0f;
    _agreeBtn.layer.masksToBounds = YES;
    [_agreeBtn setTitle:@"同意" forState:UIControlStateNormal];
    [_agreeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    _agreeBtn.backgroundColor = greenBackColor;
//    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_green_b_normal"] forState:UIControlStateNormal];
//    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_green_b_press"] forState:UIControlStateSelected];
    [_agreeBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_Sign in_normal"] forState:UIControlStateNormal];
    [_agreeBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_Sign in_press"] forState:UIControlStateHighlighted];
    
    [_agreeBtn addTarget:self action:@selector(handleLeaving:) forControlEvents:UIControlEventTouchUpInside];
//    [_agreeBtn setImage:[UIImage imageNamed:@"同意"] forState:UIControlStateNormal];
    
    _rejectBtn = [[UIButton alloc] initWithFrame:CGRectMake(15.0f + 3, 9, KSCreenW / 2.0f - 30.0f, 70.0f - 16)];//CGRectMake(15.0f + 3, 9, KSCreenW / 2.0f - 30.0f, 70.0f - 16)
    _rejectBtn.layer.cornerRadius = 5.0f;
    _rejectBtn.layer.masksToBounds = YES;
    [_rejectBtn setTitle:@"拒绝" forState:UIControlStateNormal];
    [_rejectBtn setTitleColor:[UIColor whiteColor]  forState:UIControlStateNormal];
//    _rejectBtn.backgroundColor = redBackColor;
    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_Register_normal"] forState:UIControlStateNormal];
    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_Register_Press"] forState:UIControlStateHighlighted];
//    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_red_normal"] forState:UIControlStateNormal];
//    [_rejectBtn setBackgroundImage:[UIImage imageNamed:@"HY_btn_red_press"] forState:UIControlStateSelected];
    [_rejectBtn addTarget:self action:@selector(handleLeaving:) forControlEvents:UIControlEventTouchUpInside];
//    [_rejectBtn setImage:[UIImage imageNamed:@"拒绝"] forState:UIControlStateNormal];
    
//    UIView *midLine = [ViewTool getLineViewWith:CGRectMake(_agreeBtn.width , TabbarH / 4.0, 1, TabbarH / 2.0) withBackgroudColor:grayLineColor];
//    [_btnView addSubview:midLine];
    
    [_btnView addSubview:_agreeBtn];
    [_btnView addSubview:_rejectBtn];
    
}

- (void)handleLeaving:(UIButton *)btn
{
    NSDictionary *dict;
    if ([btn.currentTitle isEqualToString:@"同意"]) {
        dict = [DataTool changeType:@{@"token" : TOKEN,@"uid" : @(UID),@"id": @(self.approID),@"lstatus": @(1)}];
    }else{
        dict = [DataTool changeType:@{@"token" : TOKEN,@"uid" : @(UID),@"id": @(self.approID),@"lstatus": @(2)}];
    }
    [self.view makeToastActivity];
    [DataTool postWithUrl:HANDLE_LEAVING_URL parameters:dict success:^(id data) {
        NSLog(@"%@",CRMJsonParserWithData(data));
        id backData = CRMJsonParserWithData(data);
        
        if([backData[@"code"] intValue] == 100){
             [self.view hideToastActivity];
            [self.view makeToast:@"处理成功"];
            [self initData];
            [UIView animateWithDuration:0.2f animations:^{
                _btnView.hidden = YES;
            }];
            
            [self performSelector:@selector(popViewControll) withObject:nil afterDelay:0.5];
        }else{
             [self.view hideToastActivity];
            [self.view makeToast:@"处理失败"];
        }
       
    } fail:^(NSError *error) {
        NSLog(@"error%@",error);
         [self.view hideToastActivity];
    }];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    [self initData];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tabBarController.hidesBottomBarWhenPushed = NO;
}

- (void)popViewControll
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
